import asyncio

from city_04_provider import CityDataProvider


class CityInfoServer:
    def __init__(self):
        self.city_provider = CityDataProvider()

    # 获取指定城市的天气信息
    async def get_city_weather(self, city: str):
        result = await self.city_provider.get_weather(city)
        return result

    # 获取所有城市列表
    async def get_city_list(self):
        result = await self.city_provider.get_city_list()
        return result

    # 获取指定城市的信息
    async def get_city_detail(self, city: str):
        result = await self.city_provider.get_city_detail(city)
        return result


async def main():
    city_server = CityInfoServer()
    city = "北京"
    city_weather_info = await city_server.get_city_weather(city)
    print("\n", city_weather_info)

    city_list = await city_server.get_city_list()
    print("\n", city_list)

    city_info = await city_server.get_city_detail(city)
    print("\n", city_info)


if __name__ == "__main__":
    asyncio.run(main())
